(function (win) {
    function memberNewNotice(title,contentList,buttonList,popContentClass){
        this.noticeModalDom=null;
        this.noticeModalStyle=null;
        this.title = title;
        this.contentList=contentList;
        this.buttonList = buttonList;
        this.popContentClass = popContentClass;
        this.agreeClicked = false;
    }
    memberNewNotice.prototype={
        constructor: memberNewNotice,
        addToast:function showToast(){
            // 创建弹窗容器
            var modal = {
                className: 'J-popups-toastpop'
            }
            modalDom = this.createNode(modal);
            // 弹窗基本结构
            var noticeModalHtml = '<div class="lay-wrap-toastpop"></div><div class="popus-cont-toastpop"></div>';
            modalDom.innerHTML=noticeModalHtml;


            console.log(modalDom.childNodes);
            
            // 弹窗内容节点
            var noticeModalContentDom = document.createDocumentFragment();

            if(this.title){
                var titleDom = this.createNode(this.title);
                noticeModalContentDom.appendChild(titleDom);
            }
            
            if(this.contentList&&this.contentList.length){
                try {
                    var contentListContainer = this.createNode({className:'content'});
                    for (var contentIndex = 0,contentLen =this.contentList.length; contentIndex < contentLen; contentIndex++) {
                        var content = this.contentList[contentIndex];
                        contentListContainer.appendChild(this.createNode(content));
                    }
                    noticeModalContentDom.appendChild(contentListContainer);
                } catch (error) {
                    
                }
            }
            if(this.buttonList&&this.buttonList.length){
                try {
                    var buttonListContainer = this.createNode({className:'btnBox'});
                    for (var btnIndex = 0,btnLen =this.buttonList.length; btnIndex < btnLen; btnIndex++) {
                        var button = this.buttonList[btnIndex];
                        buttonListContainer.appendChild(this.createNode(button));
                    }
                    noticeModalContentDom.appendChild(buttonListContainer);
                } catch (error) {
                    
                }
            }
            var childNodes = modalDom.childNodes;
            if(this.popContentClass){
                childNodes[1].className = childNodes[1].className + ' '+this.popContentClass;
            }
            childNodes[1].appendChild(noticeModalContentDom);
            document.body.appendChild(modalDom);
            this.noticeModalDom = modalDom;
        },
        /** 显示创建的弹窗节点 */
        showToast: function showToast(){
            if(this.noticeModalDom){
                this.noticeModalDom.style.display='block';
            }
        },
        /** 移除创建的弹窗节点 */
        removeToast: function removeToast(){
            if(this.noticeModalDom){
                document.body.removeChild(this.noticeModalDom);
            }
        },
        /** 隐藏创建的弹窗节点 */
        hideToast: function hideToast(){
            if(this.noticeModalDom){
                this.noticeModalDom.style.display='none';
            }
        },
        addStyle: function addStyle(){
            var noticeModalCss = '.J-popups-toastpop{width:100%;height:100%;z-index: 9;position: absolute;top: 0;left: 0;}.J-popups-toastpop .lay-wrap-toastpop{width: 100%;height: 100%;position: absolute;z-index: 88;top: 0;left: 0;background: #000;opacity: 0.6;filter: alpha(opacity=60);filter: progid:DXImageTransform.Microsoft.Alpha(opacity=60);}.J-popups-toastpop .popus-cont-toastpop{width: 524px;height: 256px;padding: 26px 30px 30px;position: absolute;z-index: 99;left: 50%; top: 50%;margin-left: -292px;margin-top:-156px;background: #fff;overflow: hidden;-webkit-border-radius: 8px;-moz-border-radius: 8px;-ms-border-radius: 8px;border-radius: 8px;}.J-popups-toastpop .popus-cont-toastpop.popus-cont_small{height:104px;margin-top:-80px;}.J-popups-toastpop .popus-cont-toastpop .title{font-weight:500;color: #333;text-align:center;line-height:24px;font-size:16px;}.J-popups-toastpop .popus-cont-toastpop .content{margin-top:9px;}.J-popups-toastpop .popus-cont-toastpop .content p{color: #333;font-size:14px;line-height:21px;}.J-popups-toastpop .popus-cont-toastpop .content p a{color: #763e82;}.J-popups-toastpop .popus-cont-toastpop .btnBox{margin-top:30px;height:50px;overflow:hidden;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn{border: 1px solid #763E82;-webkit-border-radius: 2px;-moz-border-radius: 2px;-ms-border-radius: 2px;border-radius: 2px;width:250px;height:48px;background-color:#fff;text-align:center;font-size:16px;line-height:48px;cursor:pointer;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn.btn-normal{color: #763E82;letter-spacing: 0.5px;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn.btn-primary{color: #fff;letter-spacing: 0.5px;background-color:#763e82;}';
            if(document.all){
                this.noticeModalStyle = document.createStyleSheet();
                this.noticeModalStyle.cssText = noticeModalCss;
            }else{
                this.noticeModalStyle = document.createElement('style');
            
                this.noticeModalStyle.innerHTML=noticeModalCss;
                document.getElementsByTagName('head')[0].appendChild(this.noticeModalStyle);
            }
            
        },
        addWapStyle: function addStyle(){
            var noticeModalCss = '.J-popups-toastpop{width:100%;height:100%;z-index: 9;position: absolute;top: 0;left: 0;}.J-popups-toastpop .lay-wrap-toastpop{width: 100%;height: 100%;position: absolute;z-index: 88;top: 0;left: 0;background: #000;opacity: 0.6;filter: alpha(opacity=60);filter: progid:DXImageTransform.Microsoft.Alpha(opacity=60);}.J-popups-toastpop .popus-cont-toastpop{width: 16.875rem;padding: 1.3125rem 0 0 0;position: absolute;z-index: 99;left: 50%; top: 50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background: #fff;overflow: hidden;-webkit-border-radius: 0.125rem;-moz-border-radius: 0.125rem;-ms-border-radius: 0.125rem;border-radius: 0.125rem;}.J-popups-toastpop .popus-cont-toastpop.popus-cont_small{height:6.875rem;margin-top:-4.09375rem;}.J-popups-toastpop .popus-cont-toastpop .title{font-weight:500;color: #333;text-align:center;line-height:1.5rem;font-size:1rem;}.J-popups-toastpop .popus-cont-toastpop .content{margin:0.5625rem 1.3125rem 0;}.J-popups-toastpop .popus-cont-toastpop.popus-cont_small .content{margin:0 2.3125rem 0;}.J-popups-toastpop .popus-cont-toastpop .content p{color: #333;font-size:0.875rem;line-height:1.3125rem;}.J-popups-toastpop .popus-cont-toastpop .content p a{color: #763e82;}.J-popups-toastpop .popus-cont-toastpop .btnBox{margin-top:1.3125rem;height:2.625rem;overflow:hidden;border-top:1px solid #e0e0e0;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn{box-sizing:border-box;width:8.4375rem;height:2.625rem;background-color:#fff;text-align:center;font-size:16px;line-height:2.625rem;cursor:pointer;position:relative;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn+.btn::before{content:"";position:absolute;top:0;bottom:0;width:1px;left:0;background:#e0e0e0;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn.btn-normal{color: #333;letter-spacing: 0.5px;}.J-popups-toastpop .popus-cont-toastpop .btnBox .btn.btn-primary{color: #763e82;letter-spacing: 0.5px;}';
            if(document.all){
                this.noticeModalStyle = document.createStyleSheet();
                this.noticeModalStyle.cssText = noticeModalCss;
            }else{
                this.noticeModalStyle = document.createElement('style');
            
                this.noticeModalStyle.innerHTML=noticeModalCss;
                document.getElementsByTagName('head')[0].appendChild(this.noticeModalStyle);
            }
            
        },
        /** 创建节点
         * content包含节点类型,节点内容 
         */
        createNode: function createNode(content){
            if(typeof content !=='object'){
                throw new Error('content参数必须为对象类型');
            }
            var nodeType = content.nodeType ?content.nodeType:'div';
            var element = document.createElement(nodeType);
            element.className = content.className?content.className:'';
            element.innerHTML = content.innerHTML?content.innerHTML:'';
            if(content.onClick){
                element.onclick = content.onClick;
            }
            return element;
        }
    }
    win.memberNewNotice = memberNewNotice;
})(window);